package org.jeecg.sms.model.util;

import com.alibaba.fastjson.JSON;
import lombok.Data;
import org.jeecg.common.constant.enums.MessageTypeEnum;

import org.jeecg.modules.message.entity.SysMessage;
import org.jeecg.modules.message.handle.enums.SendMsgStatusEnum;
import org.jeecg.sms.api.dto.MsgTemplateParams;

import java.util.Date;

/**
 * 短信model
 *
 * @author qiang.zhou
 * @createtime 2023-03-21  14:19
 */
@Data
public class SmsModelUtil {

    public static SysMessage buildSysMessage(String content, String phone, String title, String smsCode,String smsMode) {
        SysMessage msg = new SysMessage();
        msg.setEsTitle(title);
        msg.setEsType(MessageTypeEnum.XT.getType());
        msg.setEsReceiver(phone);
        msg.setEsContent(content);
        msg.setEsParam(JSON.toJSONString(new MsgTemplateParams(smsCode)));
        msg.setEsSendStatus(SendMsgStatusEnum.WAIT.getCode());
        msg.setCreateTime(new Date());
        msg.setUpdateTime(new Date());
        msg.setRemark(smsMode);
        return msg;
    }

}
